package com.wdy.po;

import java.io.Serializable;
import java.util.Date;

import com.wdy.util.BasicUtil;
@SuppressWarnings({"unchecked", "serial"})
public class Facility implements Comparable, Serializable {

	private Integer fid;
	private String fname;
	private String model;
	private String brand;
	private String department;
	private Date buyDate;
	private String record;
	
	public Facility() {
		super();
	}

	public Facility(Integer fid, String fname, String model, String brand,
			String department, Date buyDate, String record) {
		super();
		this.fid = fid;
		this.fname = fname;
		this.model = model;
		this.brand = brand;
		this.department = department;
		this.buyDate = buyDate;
		this.record = record;
	}

	public Integer getFid() {
		return fid;
	}

	public void setFid(Integer fid) {
		this.fid = fid;
	}

	public String getFname() {
		return fname;
	}

	public void setFname(String fname) {
		this.fname = fname;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public Date getBuyDate() {
		return buyDate;
	}

	public void setBuyDate(Date buyDate) {
		this.buyDate = buyDate;
	}

	public String getRecord() {
		return record;
	}

	public void setRecord(String record) {
		this.record = record;
	}
/*
	@Override
	public boolean equals(Object o) {
		if(null == o) {
			return false;
		}
		if(o instanceof Facility){
			Facility contrastFacility = (Facility)o;
			Integer contrastFid = contrastFacility.getFid();
			String contrastFname = contrastFacility.getFname();
			if(this.fid.equals(contrastFid) && BasicUtil.isNullOrEmpty(this.fname, contrastFname)){
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.fid.hashCode() * this.fname.hashCode();
	}
*/
	@Override
	public String toString() {
		return this.fname;
	}

	public int compareTo(Object o) {
		Facility contrastFacility = (Facility)o;
		Integer contrastFid = contrastFacility.getFid();
		int orignalId = this.fid.intValue();
		int contrastId = contrastFid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((fid == null) ? 0 : fid.hashCode());
		result = prime * result + ((fname == null) ? 0 : fname.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Facility))
			return false;
		final Facility other = (Facility) obj;
		if (fid == null) {
			if (other.fid != null)
				return false;
		} else if (!fid.equals(other.fid))
			return false;
		if (fname == null) {
			if (other.fname != null)
				return false;
		} else if (!fname.equals(other.fname))
			return false;
		return true;
	}
}
